import { Component, OnInit, ViewChild } from '@angular/core';
import { _HttpClient, ModalHelper } from '@delon/theme';
import { STColumnTag, STColumn, STComponent, STColumnBadge } from '@delon/abc';
import { GridComponent, SupDic, HttpService } from 'lbf';
import { SFComponent, SFSchema } from '@delon/form';
import { NzMessageService } from 'ng-zorro-antd';

@Component({
  selector: 'app-jgyj-sxyj',
  templateUrl: './sxyj.component.html',
})

export class JgyjSxyjComponent implements OnInit {
  queryFormData = {};  
  @ViewChild('st', { static: true }) st: GridComponent;
  @ViewChild('searchForm', { static: false }) searchForm: SFComponent;

  TAG: STColumnTag = {
    1: { text: '正常', color: 'green' },
    2: { text: '将到期', color: 'orange'},
    3: { text: '黄牌', color: 'yellow' },
    4: { text: '红牌', color: 'red' },
  };

  searchSchema: SFSchema = {
    properties: {
      YJZ002: {
        type: 'string',
        title: '预警类型',
        enum: this.dic.getSFDic('JGZ002'),
        ui: {
          widget: 'select',
        }
      },
    },
    ui: {
      spanLabelFixed: 100,
      grid: {
        span: 6
      }
    }
  };

  gridData = [];
  columns: STColumn[] = [
    { title: '事项预警序号', index: 'YJZ001'},
    { title: '预警类型', index: 'YJZ002' ,type: 'tag', tag: this.TAG },
    { title: '对应事项', index: 'DAD017' ,dic: 'DAD017' },
    // { title: '对应子项', index: 'DAE001' },
    { title: '受理对象名称', index: 'DAD075' },
    { title: '受理证件号码', index: 'DAD070' },
    { title: '对应环节', index: 'DAD090' ,dic: 'DAD090' },
    { title: '办理时限', index: 'DAD101' },
    { title: '开始时间', index: 'DAD096' },
    { title: '超限时长', index: 'YJZ003' },  
    { title: '操作员', index: 'YJZ004' ,dic: 'USERID' },  
  ];

  add(){
    this.lbs.lbservice('sxyj_sxyj', {  }).then(resdata => {
      // console.log(this.addWindow.value);
      if (resdata.code < 1) {
        this.msgSrv.error(resdata.errmsg);
      }
      else {
        this.msgSrv.success('刷新成功');
        this.query();
      }
    })  
  }
  
  query() {     
    this.st.reload(this.searchForm.value);
  }

  constructor(private http: _HttpClient,
    private dic: SupDic,
    private lbs: HttpService,
    public msgSrv: NzMessageService) { }
  ngOnInit() { 

  }

  // tslint:disable-next-line: use-lifecycle-interface
  ngAfterViewInit() {
    this.query();
  }
}
